package main

import (
	"fmt"
	"github.com/astaxie/beego"
	"github.com/astaxie/beego/orm"
	_ "github.com/go-redis/redis"
	_ "github.com/go-sql-driver/mysql"
	_ "k8s.io/client-go/kubernetes"
	// _ "sesm/routers"
)

func init() {
	orm.RegisterDriver("mysql", orm.DRMySQL)
	mysqluser := beego.AppConfig.String("mysqluser")
	mysqlpasswd := beego.AppConfig.String("mysqlpasswd")
	mysqlhost := beego.AppConfig.String("mysqlhost")
	mysqlport := beego.AppConfig.String("mysqlport")

	// orm.RegisterDataBase("default", "mysql", "dev:1234@tcp(192.168.61.128:3306)/esmtest?charset=utf8")
	err := orm.RegisterDataBase("default", "mysql", mysqluser+":"+mysqlpasswd+"@tcp"+"("+mysqlhost+":"+mysqlport+")"+"/esmtest?charset=utf8")
	if err != nil {
		fmt.Println("connect to mysql failed!")
	}
}

func main() {
	orm.Debug = true
	if beego.BConfig.RunMode == "dev" {
		beego.BConfig.WebConfig.DirectoryIndex = true
		beego.BConfig.WebConfig.StaticDir["/swagger"] = "swagger"
	}

	beego.Run()
}
